package jmine.tec.hydra.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.hydra.api.HydraMessage;
import jmine.tec.hydra.domain.message.HydraConversation;
import jmine.tec.hydra.domain.message.HydraMessageImpl;
import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Index;

import org.hibernate.validator.NotNull;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;

/**
 * Entidade criada para simular uma entidade que possua associação com uma conversa e uma mensagem do hydra.
 */
@Entity
@Table(name = "HYDRA_MY_ENTITY")
@Alias("HYDMYE")
@SequenceGenerator(name = "SEQ_HYDMYE", sequenceName = "SEQ_HYDMYE")
@Documentation("TABELA DE TESTES.")
public class MockEntity extends PersistableBusinessObject {

    private Long id;

    private HydraConversation conversation;

    private HydraMessage message;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_HYDMYE")
    @Column(name = "COD_HYDMYE", nullable = false)
    @Documentation("TABELA DE TESTES.")
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Index(suffix = "JT_0")
    @NotNull
    @ManyToOne
    @JoinColumn(name = "COD_HYDRA_CONVERSATION")
    @Documentation("TABELA DE TESTES.")
    public HydraConversation getConversation() {
        return this.conversation;
    }

    public void setConversation(HydraConversation conversation) {
        this.conversation = conversation;
    }

    @Index(suffix = "JT_1")
    @NotNull
    @ManyToOne(targetEntity = HydraMessageImpl.class)
    @JoinColumn(name = "COD_HYDRA_MESSAGE")
    @Documentation("TABELA DE TESTES.")
    public HydraMessage getMessage() {
        return this.message;
    }

    public void setMessage(HydraMessage message) {
        this.message = message;
    }

}
